<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS -->
	<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
	<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
	<link rel="stylesheet" type="text/css" href="../../css/responsive.css">
	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
	<!-- datatable -->
	<link rel="stylesheet" href="../../js/datatables/datatable.css">
	<link rel="stylesheet" href="../../js/datepicker/datepicker.css">
	<style>
		.data-sta-top .data-sta-btn {
			float: left;
			margin-right: 10px;
		}

		.data-sta .active {
			background-color: transparent;
			color: #000;
		}

		.data-sta .data-sta-money {
			line-height: 30px;
			padding: 10px 0;
		}

		.data-sta .data-sta-money em {
			font-style: normal;
			font-size: 18px;
			margin-left: 5px;
			color: #f60;
		}

		.data-sta .data-sta-money span {
			min-width: 100px;
			margin-right: 60px;
			display: inline-block;
		}

		.index-term {
			line-height: 34px;
		}

		.index-term .radio-inline input {
			margin-top: 9px;
		}
	</style>
</head>

<body>
	<header class="navbar clearfix" id="header"> </header>

	<!-- PAGE -->
	<section id="page">
		<!-- SIDEBAR -->
		<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">

				<!-- SIDEBAR MENU -->
				<ul>
				</ul>
			</div>


		</div>
		<!-- /SIDEBAR -->
		<div id="main-content">

			<div class="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- STYLER -->

									<!-- /STYLER -->
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="index.html">首页</a>
										</li>
										<li>
											<a href="#">营销管理</a>
										</li>
										<li>优惠劵</li>
									</ul>
									<!-- /BREADCRUMBS -->

								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<div class="row">
							<div class="col-md-12">
								<div class="row">
									<div class="col-md-12">
										<div class="box border primary">
											<div class="box-title">
												<h4>
													<i class="fa fa-bars"></i>
													查询条件
												</h4>
											</div>
											<div class="box-body ">
												<form class="form-horizontal data-sta-top">
													<div class="form-group mrg-bt10" id="dateChangeBtns">
														<label class="col-sm-1 control-label" style="width: auto;line-height: 34px;vertical-align: middle;">时间：</label>
														<!-- <a href="javascript:;" class="btn btn-default btn-primary data-sta-btn">今天</a>
														<a href="javascript:;" class="btn btn-default data-sta-btn">昨天</a>
														<a href="javascript:;" class="btn btn-default  data-sta-btn">最近7天</a>
														<a href="javascript:;" class="btn btn-default data-sta-btn">最近30天</a>
														<a href="javascript:;" class="btn btn-default data-sta-btn">本月</a>
														<a href="javascript:;" class="btn btn-default data-sta-btn">上月</a> -->
														<div class="col-md-2" style="min-width: 250px;">
															<input class="form-control" type="text" placeholder="Default input" style="display: inline-block" name="data-dates">
														</div>
													</div>
												</form>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>
											<span class="hidden-inline-mobile">品牌数据</span>
										</h4>
									</div>
									<div class="box-body  data-sta">
										<div class="tabbable">
											<ul class="nav nav-tabs">
												<li class="active ">
													<a href="#tab_1_1" data-toggle="tab" class="date">品牌日报</a>
												</li>
												<li class="">
													<a href="#tab_1_2" data-toggle="tab" class="month">品牌月报</a>
												</li>
											</ul>
										</div>
										<div class="data-sta-money" id="trade">
											<span class="yiguo-price">壹果交易金额:
												<em>0.00</em>
											</span>
											<span class="yiguo-grossMargin">壹果毛利:
												<em>0%</em>
											</span>
											<span class="outher-price">第三方交易额:
												<em>0.00</em>
											</span>
											<span class="outher-grossMargin">第三方毛利:
												<em>0%</em>
											</span>
										</div>
										<form class="form-horizontal index-term" action="#">
											<div class="form-group">
												<label class="col-md-1 control-label" style="width: auto;line-height: 34px;vertical-align: middle;">指标项:</label>
												<div class="col-md-11">
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="payOrderCount">支付订单数</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="payOrderPrice" checked='checked'>支付订单金额</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="payUserCount">支付用户数</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="totalCostPrice">成本</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="grossMargin">毛利</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="totalOrderCount">总订单数</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="totalOrderPrice">总订单金额</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="totalUserCount">总下单用户数</label>
													<label class="radio-inline">
														<input type="radio" class="uniform" name="pieDateOption" value="totalSalePrice">商品总销售额</label>
												</div>
											</div>
										</form>
										<div class="data-sta-box">
											<div class="row">
												<div class="col-md-3">
													<div id="data-sta-own" style="width: 100%;height:250px;"></div>
												</div>
												<div class="col-md-9">
													<div id="data-sta-outher" style="width: 100%; height: 400px;"></div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- FORMS QUERY-->
						<!-- /FORMS QUERY -->

						<div class="row">
							<!-- TABLES -->
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border primary">
									<div class="box-title">
										<h4>
											壹果合计：
											<span id="ygtotal">0.00</span>
											第三方品牌合计：
											<span id="othertotal">0.00</span>
										</h4>
									</div>
									<div class="box-body">
										<table id="db_report_list" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">

										</table>
									</div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /TABLES -->


						<div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i>
								Top
							</span>
						</div>
					</div>
					<!-- /CONTENT-->
				</div>
			</div>
		</div>
	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
	<!-- spinner -->
	<script src="../../js/spinner/spin.js"></script>
	<!-- BOOTSTRAP -->
	<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- BLOCK UI -->
	<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>

	<!-- AUTOSIZE -->
	<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
	<!-- DATA TABLES -->
	<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
	<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>
	<script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>
	<!-- SELECT2 -->
	<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
	<!-- UNIFORM -->
	<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
	<!-- COOKIE -->
	<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
	<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
	<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
	<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
	<!-- CUSTOM SCRIPT -->
	<script src="../../js/script.js"></script>
	<script src="../../js/common.js"></script>
	<script src="../../js/echarts.min.js"></script>
	<script>		
		$(function () {
			var dataSta = {
				isToday: false,
				startDate: '', // 开始时间 v2
				endDate: '', // 结束时间
				date: '', // 今天时间
				nextDate: '', // 明天
				dataStyle: 'date', // 数据请求类型 默认日报 date || month,
				pieDateOption: 'payOrderPrice', // 饼状图对比类型
				pieDateOptionObject: {
					payOrderCount: '支付订单数',
					payOrderPrice: '支付订单金额',
					payUserCount: '支付用户数',
					totalCostPrice: '成本',
					grossMargin: '毛利',
					totalOrderCount: '总订单数',
					totalOrderPrice: '总订单金额',
                    totalUserCount: '总下单用户数',
                    totalSalePrice: '商品总销售额'
				},
				pieDate: [], // 饼状图数据
				lineDate: [], // 折线图数据
				pieDateUrl: 'admin/report/supplierOrderReportWithSplitYG.do', // 饼状图日报地址
				pieMonthUrl: 'admin/report/supplierOrderReportWithSplitYGByMonth.do', // 饼状图月报请求地址
				lineDateUrl: 'admin/report/supplierOrderReportByDay.do', // 折线图日报地址
				lineMonthUrl: '/admin/report/supplierOrderReportByMonth.do', // 折线图月报地址
				init: function () {
					// 初始化时间
					this.startDate = this.endDate = this.date = new Date().format('yyyy-MM-dd');
					this.nextDate = new Date(new Date().getTime() + 86400000).format('yyyy-MM-dd');
					this.initDataStyle();
					this.initDataSelect();
					this.initPieDateOptionChange();
					this.getDate();
					// this.bindDateChange();
				},
				// 获取数据饼状图 和 线形图的数据
				getDate: function (startDate, endDate) {
					if (this.date == this.startDate && this.date == this.endDate) {
						this.isToday = true;
					} else {
						this.isToday = false;
					}
					var that = this,
						startDate = this.startDate,
						endDate = $.dateAdd(this.endDate);
					pieUrl = '',
						lineUrl = '';
					if (this.isToday && this.dataStyle == 'date') {	// 今天
						this.getDateFun(this.date, this.nextDate, '/admin/report/searchOrderReportBySupplier.do', function (result) {
							that.lineDate = result.data;
							that.createDataLine();
							that.pieDate = result.data;
							that.createDataPie();
							that.createTrade();
							that.searchTableDate();
						})
					} else { // 非今天
						pieUrl = (this.dataStyle == 'date' ? this.pieDateUrl : this.pieMonthUrl);
						lineUrl = (this.dataStyle == 'date' ? this.lineDateUrl : this.lineMonthUrl);
						this.getDateFun(startDate, endDate, pieUrl, function (result) {
							that.pieDate = result.extra;
							that.createDataPie();
							that.createTrade();
							that.searchTableDate();
						})
						this.getDateFun(startDate, endDate, lineUrl, function (result) {
							that.lineDate = result.extra;
							that.createDataLine();
						})
					}
				},
				// 请求数据的方法
				getDateFun: function (startDate, endDate, url, fun) {
					$.ajax({
						type: 'get',
						url: App.getContextPath() + url,
						data: { startDate: startDate, endDate: endDate },
						async: true,
						success: function (result) {
							fun && fun(result)
						}
					});
				},
				// 折线图
				createDataLine: function () {
					var that = this,
						date = this.lineDate,
					  selected = {},
						dataNames = [],
						dataSeries = [],
						dataTimes = [],
						indexNum = 0;
					if (this.isToday && this.dataStyle == 'date') {
						if (!date.length) {
							return;
						}
						date.forEach(function (item) {
							dataNames.push(item.supplierName);
							if (indexNum < 10) {
								selected[item.supplierName] = true
							} else {
								selected[item.supplierName] = false
							}
							indexNum++;
							var arr = [];
							arr.push(item[that.pieDateOption]);
							dataSeries.push({
								name: item.supplierName,
								type: 'line',
								data: arr
							})
						})
						dataTimes.push(that.date);
					} else {
						for (var key in date) {
							if (date.hasOwnProperty(key)) {
								dataNames.push(key);
								if (indexNum < 10) {
									selected[key] = true
								} else {
									selected[key] = false
								}
								indexNum++;
								var obj = {
									name: key,
									type: 'line',
									data: []
								};
								date[key].forEach(function (item) {
									if (dataTimes.length < date[key].length) {
										if (that.dataStyle == 'date') {
											dataTimes.push(new Date(item.orderDate).format('yyyy-MM-dd'));
										} else {
											dataTimes.push(item.month);
										}
									}
									obj.data.push(item[that.pieDateOption])
								});
								//obj.data = obj.data.reverse();
								dataSeries.push(obj);
							}
						}
						//dataTimes = dataTimes.reverse();
					}
					var myChart = echarts.init(document.getElementById('data-sta-outher'));
					option = {
						title: {
							text: '第三方品牌对比'
						},
						tooltip: {
							trigger: 'axis'
						},
						legend: {
							type: 'scroll',
							orient: 'vertical',
							right: 0,
							top: 50,
							data: dataNames,
							selected: selected
						},
						grid: {
							left: '3%',
							right: '180',
							bottom: '10%',
							containLabel: true
						},
						// toolbox: {
						// 	feature: {
						// 		saveAsImage: {}
						// 	}
						// },
						xAxis: {
							type: 'category',
							boundaryGap: false,
							data: dataTimes
						},
						yAxis: {
							type: 'value'
						},
						dataZoom: [{
							show: dataTimes.length > 7,
							realtime: true,
							start: 0,
							end: (7 / dataTimes.length) * 100,
						}],
						series: dataSeries
					};
					myChart.setOption(option);
				},
				// 创建饼状图
				/**
				 * optionName [String] 饼状图比较类型 例如 totalOrderPrice --- 支付订单金额 
				 * data [Array] 饼状图数据
				 **/
				createDataPie: function () {
					var pieDate = this.pieDate;
					pieDateOption = this.pieDateOption,
						optionName = this.pieDateOptionObject[pieDateOption],
						newData = [],
						dataNames = [],
						that = this,
						// 基于准备好的dom，初始化echarts实例
						myChart = echarts.init(document.getElementById('data-sta-own'));
					// 当时第一天时候，重新组合一下数据
					if (that.isToday && that.dataStyle == 'date') {
						if (!pieDate.length) {
							return;
						}
						var yiigooObj = {},
							otherObj = {
								createTime: null,
								id: null,
								month: null,
								orderDate: null,
								supplierId: 0,
								supplierName: '第三方品牌',
								payOrderCount: 0,
								payOrderPrice: 0,
								payUserCount: 0,
								totalCostPrice: 0,
								totalOrderCount: 0,
								totalOrderPrice: 0,
                                totalUserCount: 0,
                                grossMargin: 0,
                                totalSalePrice: 0
							};
						pieDate.forEach(function (item) {
							if (item.supplierName == '壹果') {
								yiigooObj = {
									createTime: null,
									grossMargin: item.grossMargin,
									id: null,
									month: null,
									orderDate: null,
									payOrderCount: item.payOrderCount,
									payOrderPrice: item.payOrderPrice,
									payUserCount: item.payUserCount,
									status: null,
									supplierId: 1,
									supplierName: '壹果',
									totalCostPrice: item.totalCostPrice,
									totalOrderCount: item.totalOrderCount,
									totalOrderPrice: item.totalOrderPrice,
                                    totalUserCount: item.totalUserCount,
                                    totalSalePrice: item.totalSalePrice
								}
							} else {
								otherObj.payOrderCount += item.payOrderCount;
								otherObj.payOrderPrice += item.payOrderPrice;
								otherObj.payUserCount += item.payUserCount;
								otherObj.totalCostPrice += item.totalCostPrice;
								otherObj.totalOrderCount += item.totalOrderCount;
								otherObj.totalOrderPrice += item.totalOrderPrice;
                                otherObj.totalUserCount += item.totalUserCount;
                                otherObj.totalSalePrice += item.totalSalePrice;
							}
						});
						var arr = [];
						otherObj.payOrderPrice = otherObj.payOrderPrice.toFixed(2);
						otherObj.totalCostPrice = otherObj.totalCostPrice.toFixed(2);
						otherObj.totalOrderPrice = otherObj.totalOrderPrice.toFixed(2);
						otherObj.grossMargin = ((otherObj.payOrderPrice - otherObj.totalCostPrice) / otherObj.payOrderPrice * 100).toFixed(2);
                        otherObj.totalSalePrice = otherObj.totalSalePrice.toFixed(2);
						arr.push(yiigooObj, otherObj);
						pieDate = arr;
					}
					// 过滤一下饼状图数据 该变成对应的格式的数据
					pieDate.forEach(function (item) {
						var name = item.supplierName == '壹果' ? '壹果' : '第三方品牌';
						newData.push({
							value: item[pieDateOption],
							name: name
						});
						dataNames.push(name);
					});
					// 指定图表的配置项和数据
					var option = {
						tooltip: {
							trigger: 'item',
							formatter: "{a} <br/>{b}: {c} ({d}%)"
						},
						grid: {
							top: 30,    //距离容器上边界40像素
							bottom: 30,
							left: 30,
							right: 30   //距离容器下边界30像素
						},
						legend: {
							x: 'center',
							y: 'bottom',
							data: dataNames
						},
						series: [{
							name: optionName,
							type: 'pie',
							radius: ['50%', '70%'],
							avoidLabelOverlap: false,
							label: {
								normal: {
									show: false,
									position: 'center'
								},
								emphasis: {
									show: true,
									textStyle: {
										fontSize: '20',
										fontWeight: 'bold'
									}
								}
							},
							labelLine: {
								normal: {
									show: false
								}
							},
							data: newData
						}]
					};

					// 使用刚指定的配置项和数据显示图表。
					myChart.setOption(option);
				},
				// 创建交易信息
				createTrade: function () {
					var data = this.pieDate,
						that = this;
					$("#trade .yiguo-price em").text('0.00');
					$("#trade .yiguo-grossMargin em").text('0%');
					$("#trade .outher-price em").text('0.00');
					$("#trade .outher-grossMargin em").text('0%');
					$("#ygtotal").text("0.00");
					$("#othertotal").text("0.00");
					if (that.isToday && that.dataStyle == 'date') {
						var yiguoPrice = 0,
							yiguoGrossMargin = 0,
							outerTotalCostPrice = 0,
							outerPayOrderPrice = 0;
						data.forEach(function (item) {
							if (item.supplierName == '壹果') {
								yiguoPrice = item.payOrderPrice;
								yiguoGrossMargin = item.grossMargin;
							} else {
								outerTotalCostPrice += item.totalCostPrice;
								outerPayOrderPrice += item.payOrderPrice;
							}
						});
						yiguoPrice = that.formatNumber(yiguoPrice, 2, ',');
						$("#trade .yiguo-price em").text(yiguoPrice);
						$("#ygtotal").text(yiguoPrice);
						$("#trade .yiguo-grossMargin em").text(yiguoGrossMargin + '%');
						var lilv = (outerPayOrderPrice - outerTotalCostPrice) / outerPayOrderPrice;
						if ((outerPayOrderPrice - outerTotalCostPrice) < 0) {
							lilv = 0;
						}
						outerPayOrderPrice = that.formatNumber(outerPayOrderPrice, 2, ',');
						$("#trade .outher-price em").text(outerPayOrderPrice);
						$("#othertotal").text(outerPayOrderPrice);
						$("#trade .outher-grossMargin em").text(that.formatNumber(lilv * 100, 2, ',') + '%');
					} else {
						data.forEach(function (item) {
							if (item.supplierName == '壹果') {
								var payOrderPrice = that.formatNumber(item.payOrderPrice, 2, ',');
								$("#trade .yiguo-price em").text(payOrderPrice);
								$("#ygtotal").text(payOrderPrice);
								$("#trade .yiguo-grossMargin em").text(item.grossMargin + '%');
							} else {
								var payOrderPrice = that.formatNumber(item.payOrderPrice, 2, ',');
								$("#trade .outher-price em").text(payOrderPrice);
								$("#othertotal").text(payOrderPrice);
								$("#trade .outher-grossMargin em").text(item.grossMargin + '%');
							}
						})
					}
				},
				initDataStyle: function () {
					var that = this;
					// 初始化请求类型
					$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
						var IsDate = $(e.target).hasClass('date');
						that.dataStyle = IsDate ? 'date' : 'month';
            that.getDate();
					});
				},
				initDataSelect: function () {
					var that = this;
					// 初始化日期选择器
					$('input[name="data-dates"]').daterangepicker({
						"locale": {
							format: 'YYYY-MM-DD',
							applyLabel: "应用",
							cancelLabel: "取消",
							resetLabel: "重置",
							customRangeLabel: "自定义",
							daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
							monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
						},
						ranges: {
							'今天': [moment(), moment()],
							'昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
							'最近7天': [moment().subtract(6, 'days'), moment()],
							'最近30天': [moment().subtract(29, 'days'), moment()],
							'本月': [moment().startOf('month'), moment().endOf('month')],
							'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
						},
					}, function (start, end, label) {
						that.startDate = this.startDate.format(this.locale.format);
						that.endDate = this.endDate.format(this.locale.format);
						that.getDate(that.startDate, that.endDate);
						if (!this.startDate) {
							this.element.val('');
						} else {
							this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
						}
					});
				},
				// PieDateOptionChange 监控
				initPieDateOptionChange: function () {
					var that = this;
					$("input[name='pieDateOption']").each(function () {
						$(this).click(function () {
							that.pieDateOption = $(this).val();
							that.createDataPie();
							that.createDataLine();
						})
					})
				},
				// table数据初始化
				searchTableDate: function () {
					var dataStyle = this.dataStyle,
						$mainDataTable = null,
						startDate = this.startDate,
						endDate = this.endDate,
						that = this;
					url = App.getContextPath() + (dataStyle == 'date' ? "admin/report/searchSupplierOrderReport.do" : "admin/report/searchSupplierOrderReportByMonth.do");
					if (this.isToday && this.dataStyle == 'date') {
						url = App.getContextPath() + "admin/report/searchOrderReportBySupplier.do";
						//endDate = this.nextDate;
					}
					url += "?startDate=" + startDate;
					url += "&endDate=" + $.dateAdd(endDate);
					if ($mainDataTable) {
						$mainDataTable.api().ajax.url(url).load();
						return;
					}
					var dtSetting = $.dataTableSetting({
						"ajaxSource": url,
						"serverSide": true,
						"bFilter": false,// 去掉搜索框
						"bLengthChange": true,// 每页显示数量							
						"sScrollX": "100%",
						"sScrollXInner": "100%",
						"iDisplayLength": 25,
						"bSort": false,
						"aoColumns": [{
							"mDataProp": "orderDate",
							"sTitle": "日期",
							"width": "10%",
							"render": function (data, type, row) {
								if (dataStyle == 'date') {
									return row.orderDate ? new Date(row.orderDate).format("yyyy-MM-dd") : that.date;
								} else {
									return row.month || that.date
								}
							}
						}, {
							"mDataProp": "supplierName",
							"sTitle": "品牌",
							"width": "10%",
							"render": function (data, type, row) {
								return row.supplierName || row.supplierName || '壹果'
							}
						}, {
							"mDataProp": "totalOrderCount",
							"sTitle": "总订单数",
							"width": "8%",
							"class": "format_number"
						}, {
							"mDataProp": "totalOrderPrice",
							"sTitle": "总订单金额",
							"width": "10%",
							"class": "format_thousands"
						}, {
							"sTitle": "总下单用户数",
							"mDataProp": "totalUserCount",
							"width": "8%",
							"class": "format_number"
						}, {
							"sTitle": "支付订单数",
							"mDataProp": "payOrderCount",
							"width": "8%",
							"class": "format_number"
						}, {
							"sTitle": "支付订单金额",
							"mDataProp": "payOrderPrice",
							"width": "10%",
							"class": "format_thousands"
						}, {
							"sTitle": "支付用户数",
							"mDataProp": "payUserCount",
							"width": "8%",
							"class": "format_number"
						}, {
                            "sTitle": "总成本",
                            "mDataProp": "totalCostPrice",
                            "width": "10%",
                            "class": "format_number"
                        }, {
                            "sTitle": "商品销售总额",
                            "mDataProp": "totalSalePrice",
                            "width": "10%",
                            "class": "format_number"
                        }, {
							"sTitle": "毛利率",
							"mDataProp": "grossMargin",
							"width": "10%",
							"class": "format_number",
							"render": function (data, type, row) {
								return format_thousands(data) + '%'
								//return format_thousands((row.payOrderPrice - row.totalCostPrice) / (row.payOrderPrice == 0 ? 1 : row.payOrderPrice) * 100) + "%";
							}
						}]
					});
					$mainDataTable = $("#db_report_list").dataTable(dtSetting);
				},
				formatNumber: function (num, cent, isThousand) {
					num = num.toString().replace(/\$|\,/g, '');
					// 检查传入数值为数值类型  
					if (isNaN(num))
						num = "0";
					// 获取符号(正/负数)  
					sign = (num == (num = Math.abs(num)));
					num = Math.floor(num * Math.pow(10, cent) + 0.50000000001);  // 把指定的小数位先转换成整数.多余的小数位四舍五入  
					cents = num % Math.pow(10, cent);              // 求出小数位数值  
					num = Math.floor(num / Math.pow(10, cent)).toString();   // 求出整数位数值  
					cents = cents.toString();               // 把小数位转换成字符串,以便求小数位长度  
					// 补足小数位到指定的位数  
					while (cents.length < cent)
						cents = "0" + cents;
					if (isThousand) {
						// 对整数部分进行千分位格式化.  
						for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
							num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
					}
					if (cent > 0)
						return (((sign) ? '' : '-') + num + '.' + cents);
					else
						return (((sign) ? '' : '-') + num);
				},
				// bindDateChange: function () {
				// 	$("#dateChangeBtns .btn").each(function(){
				// 		$(this).click(function(){
				// 			if ($(this).hasClass('btn-primary')) {
				// 				return;
				// 			} else {
				// 				var text = $(this).text();
				// 				$(".daterangepicker .ranges li:contains(" + text + ")").trigger('click');
				// 				$("#dateChangeBtns input[name='data-dates']").focus().blur();
				// 				$(this).addClass('btn-primary').siblings('.btn-primary').removeClass('btn-primary')
				// 			}
				// 		})
				// 	})
				// }
			}
			$("#header").load("../head.html");
			App.init(); //Initialise plugins and elements	 
			dataSta.init();
		});
	</script>
	<!-- /JAVASCRIPTS -->
</body>

</html>